package flexo.scene;

import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;

public class SceneSystem extends flexo.common.System
{	
	public static final String ID = "scene";
	
	protected List<Scene> sceneList;
	
	public SceneSystem()
	{
		super(ID,flexo.common.System.UPDATE_NONE);
		sceneList = new LinkedList<Scene>();
	}
	
	public Scene addScene(String name)
	{
		Scene s = getScene(name); 
		if (s == null)
		{
			s = new Scene(name);
			sceneList.add(s);
		}
		return s;
	}
	
	public Scene getScene(String name)
	{
		Iterator<Scene> iter = sceneList.iterator();
		
		while (iter.hasNext())
		{
			Scene s = iter.next();
			if (s.getName().equals(name))
			{
				return s;
			}
		}
		return null;
	}
	
	public void removeScene(String name)
	{
		Iterator<Scene> iter = sceneList.iterator();
		
		while (iter.hasNext())
		{
			Scene s = iter.next();
			if (s.getName().equals(name))
			{
				iter.remove();
			}
		}
	}
}
